package com.itheima.charest;

import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;

public class Test02 {
    public static void main(String[] args) throws IOException {
        method1();
        FileReader fr=new FileReader("ChaStream\\ab.txt");
        byte[] bytes=new byte[1024];
        int len;
        while ((len=fr.read())!=-1){
            System.out.println((char)len);
        }
        fr.close();
    }

    private static void method1() throws IOException {
        Scanner sc=new Scanner(System.in);
        System.out.println("请输入用户名");
        String username=sc.nextLine();
        System.out.println("请输入密码");
        String password=sc.nextLine();
        FileWriter fw=new FileWriter("ChaStream\\ab.txt");
        fw.write(username);
        fw.write("\r\n");
        fw.write(password);
        fw.close();
    }
}
